package com.office.stacks.center.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.office.common.annotation.Log;
import com.office.common.core.controller.BaseController;
import com.office.common.core.domain.AjaxResult;
import com.office.common.enums.BusinessType;
import com.office.stacks.center.domain.TasksCenter;
import com.office.stacks.center.service.ITasksCenterService;
import com.office.common.utils.poi.ExcelUtil;
import com.office.common.core.page.TableDataInfo;

/**
 * 任务中心Controller
 *
 * @author 柒月
 * @date 2025-05-27
 */
@RestController
@RequestMapping("/center/assignment")
public class TasksCenterController extends BaseController {
    @Autowired
    private ITasksCenterService tasksCenterService;

    /**
     * 查询任务中心列表
     */
    @PreAuthorize("@ss.hasPermi('center:assignment:list')")
    @GetMapping("/list")
    public TableDataInfo list(TasksCenter tasksCenter) {
        startPage();
        List<TasksCenter> list = tasksCenterService.selectTasksCenterList(tasksCenter);
        return getDataTable(list);
    }

    /**
     * 导出任务中心列表
     */
    @PreAuthorize("@ss.hasPermi('center:assignment:export')")
    @Log(title = "任务中心", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TasksCenter tasksCenter) {
        List<TasksCenter> list = tasksCenterService.selectTasksCenterList(tasksCenter);
        ExcelUtil<TasksCenter> util = new ExcelUtil<TasksCenter>(TasksCenter.class);
        util.exportExcel(response, list, "任务中心数据");
    }

    /**
     * 接下任务
     */
    @PreAuthorize("@ss.hasPermi('center:assignment:take')")
    @PutMapping("/tack/{ids}/{fileId}")
    public AjaxResult take(@PathVariable Long ids, @PathVariable Long fileId) {
        return AjaxResult.success(tasksCenterService.updateTasksCenterTake(ids, fileId));
    }
}
